package com.owc.controller.admin;

import com.owc.domain.BaseResult;
import com.owc.domain.dto.admin.FundsDTO;
import com.owc.domain.dto.admin.RefreshInfoDTO;
import com.owc.domain.vo.admin.FundsVo;
import com.owc.service.admin.FundsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author xiaom
 * @Date 2019/12/20 10:14
 * @Version 1.0.0
 * @Description <>
 **/
@RestController
@RequestMapping(value = "/admin/funds")
public class FundsController {

    @Autowired
    private FundsService fundsService;

    @PostMapping(value = "/list")
    public BaseResult<List<FundsDTO>> list(@RequestBody @Valid FundsVo fundsVo){
        return fundsService.list(fundsVo);
    }

    @PostMapping(value = "/refresh")
    public BaseResult<Boolean> refreshTokenBalance(@RequestBody @Valid FundsVo fundsVo){
        return BaseResult.success(fundsService.refreshBalance(fundsVo));
    }

    @PostMapping(value = "/getRefreshInfo")
    public BaseResult<RefreshInfoDTO> getRefreshInfo(@RequestBody FundsVo fundsVo){
        return BaseResult.success(fundsService.getRefreshInfo(fundsVo.getTokenName()));
    }
}
